package git.bankview.wl.auth;

import git.bankview.wl.auth.userGroups.TransCheck;
import git.bankview.wl.bean.LogonBean;

public class UserAuth
{
	public static void validate(LogonBean user, String transId, int nMethodId)
		throws Exception
	{
		if (null == user || !user.getLogon())
			throw new NoLoginException("exception.nologin");
		
		TransCheck.check(user.getUsername(), transId, nMethodId);
	}
	
	public static boolean validateMethod(LogonBean user, String transId, int nMethodId)
	{
		if (null == user || !user.getLogon())
			return false;
		
		if (0 != nMethodId)
		{
			try
			{
				TransCheck.check(user.getUsername(), transId, nMethodId);
			}
			catch(Exception e)
			{
				return false;
			}
		}
		
		return true;
	}
	
	public static java.util.List queryMethods(LogonBean user, String transId)
		throws Exception
	{
		return TransCheck.find(user.getUsername(), transId);
	}
}
